import vue from 'vue';
import vuex from 'vuex';
import createLogger from 'vuex/dist/logger'; // 修改日志
import state from './state';
import * as getters from './getters';
import mutations from './mutations';
import actions from './actions';
import homeStore from './modules/home/homeStore';
import newsListStore from './modules/home/newsListStore';
import newsDetailStore from './modules/home/newsDetailStore';
import imagesListStore from './modules/home/imagesListStore';
import imagesDetailStore from './modules/home/imagesDetailStore';
import goodsListStore from './modules/home/goodsListStore';

vue.use(vuex);

const debug = process.env.NODE_ENV !== 'production'; // 开发环境中为true，否则为false

export default new vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules: {
    home: {
      namespaced: true,
      modules: {
        homeStore,
        newsListStore,
        newsDetailStore,
        imagesListStore,
        imagesDetailStore,
        goodsListStore,
      },
    },
  },
  plugins: debug ? [createLogger()] : [], // 开发环境下显示vuex的状态修改
});
